<script type="text/javascript">
    $(document).ready(function() {
        $("#dialog_view").tabs();

        $("#dialog_view").dialog({
            autoOpen: false,
            height: 500,
            width: 1000,
            position: ['top', 'middle'],
            resizable: false,
            modal: true
        });

        $(".preview").click(function() {
            var id_item = $(this).attr("rel");
            // alert(id_item);
            $.get("{$config->site_url('inventarisasi/pengadaan/view_pengajuan/" + id_item + "')}", function(data) {
                $("#table-list-pengadaan").html(data);
            });
            $("#dialog_view").dialog('open')
        });

        $("#bulan_ra").select2();
        $("#tahun_ra").select2();
        $("#location_id").select2();

    });
</script> 
<div class="breadcrum">
    <p>
        <a href="#">Inventarisasi</a>
        <span></span><small>Pengadaan</small> 
    </p>
    <div class="clear"></div>
</div>
<div class="sub-content">
    <div class="search-box">
        <h3><a href="#">Search</a></h3>
        <form method="post" action="{$config->site_url('inventarisasi/pengadaan/proses_cari')}" id="form-search">
            <table width="100%" border="0" class="table-search">
                <tbody>
                    <tr> 
                        <th width="5%">Bagian</th>
                        <td width="10%">
                            <select name="bagian_cd" id="bagian_cd" style="width: 300px;">
                                <option value="%"></option>
                                {foreach from=$rs_bagian item=data}
                                <option value="{$data.bagian_cd|default:''}" {if {$ses_bagian_cd|default:''} eq $data.bagian_cd}selected="selected"{/if}>{$data.bagian_name}</option>
                                {/foreach}
                            </select>
                        </td>
                        <td width="25%"> 
                            <select id="bulan" name="bulan">
                                <option value=""></option>
                                {foreach from=$bulan item=data}
                                <option value="{$data.kode|default:''}" {if {$data.kode|default:''} eq $ses_bulan}selected="selected"{/if}>{$data.name|default:''}</option>
                                {/foreach}
                            </select> 
                            <select id="tahun" name="tahun">
                                <option value=""></option>
                                {foreach from=$tahun item=data}
                                <option value="{$data.tahun|default:''}" {if {$data.tahun|default:''} eq $ses_tahun}selected="selected"{/if}>{$data.tahun}</option>
                                {/foreach}
                            </select> 
                        </td>
                        <td>
                            <input type="submit" value="Tampilkan" name="save" class="submit">
                            <input type="submit" value="Reset" name="save" class="submit">
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </div>
    <div class="navigation"> 
        <div class="pageRow">
            <div class="pageNav">
                <ul>
                    <li class="info"><strong>{$pagination.start|default:'0'} - {$pagination.end|default:'0'}</strong> dari <strong>{$pagination.total|default:'0'}</strong> Data</li>
                    {$pagination.data|default:''}
                </ul>
            </div>
            <div class="clear"></div>
        </div>
        <div class="navigation-button">
            <ul>
                <!-- <li><a href="{$config->site_url('inventarisasi/pengadaan/import')}"><img alt="" src="{$BASEURL}/resource/doc/images/icon/up-icon.png">Import Data</a></li> -->
                <li><a href="{$config->site_url('inventarisasi/pengadaan/add')}"><img alt="" src="{$BASEURL}/resource/doc/images/icon/add-icon.png">Tambah Data</a></li> 
            </ul>
            <div class="clear"></div>
        </div>
    </div> 
    <!-- notification template -->
    {include file="base/templates/notification.html"}
    <!-- end of notification template-->  
    <table width="100%" class="table-view">
        <tbody>
            <tr>
                <th width="5%">No</th>
                <th width="10%">Tanggal</th>
                <th width="20%">Bagian</th> 
                <th width="20%">Nomor Pengadaan</th> 
                <th width="18%">Nomor Serah terima</th> 
                <th width="5%">Invoice</th>
                <th width="5%">Preview</th> 
                <th width="17%"></th>
            </tr>  
            {assign var='numb' value='1'}
            {foreach from=$rs_id key=no item=result}
            <tr {if ($no % 2) <> 0}class="blink-row"{/if}> 
                <td align="right">{$numb++}</td>
                <td>{$dtm->get_full_date($result.pengadaan_date|default:'')}</td>
                <td>{$result.bagian_name}</td>
                <td style="color: red;"><b>{$result.pengadaan_nomor}</b></td>
                <td style="color: blue;"><b>{$result.pengadaan_ba_dist}</b></td>
                <td align="center"> 
                    {if $result.pengadaan_att_surat neq ''}
                    <a href="{$filepath}{$result.pengadaan_att_surat}" data-lightbox="image-1" title="Pengadaan Nomor Surat : {$result.pengadaan_nomor|default:''}">
                        <img src="{$BASEURL}/resource/doc/images/icon/icon-1.png" />
                    </a> 
                    {/if}
                </td>
                <td align="center"> 
                    <img class="preview" rel="{$result.pengadaan_id}" src="{$BASEURL}/resource/doc/images/icon/view.png"/> 
                </td> 
                <td align="center">
                    <a href="{$config->site_url({'inventarisasi/pengadaan/distribusi/'})}/{$result.pengadaan_id}" class="button-distribusi">Distribusi</a>
                    <a href="{$config->site_url({'inventarisasi/pengadaan/edit/'})}/{$result.pengadaan_id}" class="button-edit">Edit</a>
                    <a href="{$config->site_url({'inventarisasi/pengadaan/delete/'})}/{$result.pengadaan_id}" class="button-hapus">Hapus</a>
                </td>
            </tr>
            {foreachelse}
            <tr>
                <td colspan="8">Data masih kosong</td>
            </tr>
            {/foreach}
        </tbody>
    </table> 
</div>
<div id="dialog_view" display="none" title="Detail Data"> 
    <table width="100%" class="table-view" id="table-list-pengadaan"></table>
</div> 
